Test Setup Failed
Push — master ( 8ee19e...25278d )
by recca
05:07 queued 46s
created

polyfill.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 9
rs 9.6666
c 4
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A polyfill.js ➔ ... ➔ ??? 0 3 1
1
'use strict';
2
3
import './jquery';
4
// import 'babel-polyfill';
5
6
(function() {
7
    var testObject = {};
8
9
    if (!(Object.setPrototypeOf || testObject.__proto__)) {
10
        var nativeGetPrototypeOf = Object.getPrototypeOf;
11
12
        Object.getPrototypeOf = function(object) {
0 ignored issues
show
Compatibility Best Practice introduced by
You are extending the built-in type Object. This may have unintended consequences on other objects using this built-in type. Consider subclassing instead.
Loading history...
13
            if (object.__proto__) {
14
                return object.__proto__;
15
            } else {
16
                return nativeGetPrototypeOf.call(Object, object);
17
            }
18
        }
19
    }
20
})();
21
22
if (!Object.assign) {
23
    Object.assign = $.extend;
24
}
25
26
if (!Array.prototype.includes) {
27
    Object.defineProperty(Array.prototype, 'includes', {
28
        value(...args) {
29
            return $.inArray(...args, this) !== -1;
30
        }
31
    });
32
}
33
34
class jQueryPromise {
35
    constructor(callback) {
36
        this.deferred = $.Deferred();
37
        callback((o) => {
38
            this.deferred.resolve(o);
39
        }, (o) => {
40
            this.deferred.reject(o);
41
        });
42
        this.promise = this.deferred.promise();
43
    }
44
45
    then(resolve, reject) {
46
        this.promise.done(resolve);
47
        this.promise.fail(reject);
48
        return this;
49
    }
50
51
    catch(reject) {
52
        this.promise.fail(reject);
53
        return this;
54
    }
55
}
56
57
if (!window.Promise) {
58
    window.Promise = jQueryPromise;
59
}
60